﻿using Microsoft.Extensions.Logging;
using System;
using Nest;

namespace Spark.Logging
{
    public class LogEntry
    {
        public LogEntry()
        {
            Id = Guid.NewGuid().ToString("N");
        }

        public string Id { get; set; }

        public DateTime DateTime { get; set; }

        public EventId EventId { get; set; }

        [Keyword]
        public string Level { get; set; }

        /// <summary>
        /// App名称
        /// </summary>
        [Keyword]
        public string AppCode { get; set; }

        [Keyword]
        public string ServiceName { get; set; }

        [Text]
        public string Category { get; set; }

        [Text]
        public string Message { get; set; }

        //[Keyword]
        public string TraceIdentifier { get; set; }

        public string UserName { get; set; }

        public string ContentType { get; set; }

        public string Host { get; set; }

        public string Method { get; set; }

        public string Protocol { get; set; }

        public string Scheme { get; set; }

        public string Path { get; set; }

        public string PathBase { get; set; }

        public string QueryString { get; set; }

        [Text]
        public string Body { get; set; }

        public long? ContentLength { get; set; }

        public bool IsHttps { get; set; }

        // public IRequestCookieCollection Cookies { get; set; }
        //public IHeaderDictionary Headers { get; set; }

        //[Keyword]
        public string ExceptionType { get; set; }

        [Text]
        public string ExceptionMessage { get; set; }

        public string Exception { get; set; }

        public bool HasException => Exception != null;

        public string StackTrace { get; set; }
    }
}